﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using MLRobotic.Tower.Forms;
using MLRobotic.Tower.Common;
using MLRobotic.Tower.Messaging;

namespace MLRobotic.Tower
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var config = new Config();

            using (var controlTower = new ControlTower(config))
            {
                Application.Run(new DetectionForm(controlTower, config));
            }
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            new Log("Program").Error("Unhandled exception", (Exception)e.ExceptionObject);
        }
    }
}